import axios from 'helpers/axios'
import {  ISearchHot ,ISearchSuggestRequest, ISearchSuggestResponse, } from './types/search'
import { TARGET_TYPE } from './types/business'
import { PAGE_SIZE } from 'constants/pagination'
//https://blog.csdn.net/weixin_34204722/article/details/87961589
//https://blog.csdn.net/wu_xianqiang/article/details/103483616

//数据结构 http://47.115.57.59:3000/search/hot
//[{first: "星辰大海", second: 1, third: null, iconType: 1},…]
type SearchHotFn = ()=> Promise<ISearchHot[]>
type SearchSuggestFn = (params: ISearchSuggestRequest) => Promise<ISearchSuggestResponse>

const searchHot : SearchHotFn  = async () => {
  const response = await axios({
    url: '/search/hot',
  })
  return response.result.hots
}


const searchSuggest: SearchSuggestFn = async ({ keywords }) => {
  const response = await axios({
    url: '/search/suggest',
    params: {
      keywords,
    },
  })

  return response.result
}




export default {
  searchHot,
  searchSuggest
}
